const express = require('express');
const mysql = require('mysql');
const router = express.Router();
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: '123456',
  database: 'patrol_db',
});
router.post('/', (req, res) => {
  const { room_name, created_by, updated_by } = req.body;
  const query = `INSERT INTO room (room_name, created_by, updated_by) VALUES ('${room_name}', '${created_by}', '${updated_by}')`;
  connection.query(query, (err, result) => {
    if (err) {
      console.log(err);
      res.status(500).send('Error adding room');
    } else {
      res.status(200).send('Room added successfully');
    }
  });
});
module.exports = router;
